#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
using ll = long long;
const int N = 2000010;
int n, mod;
int primes[N], cnt;
bool st[N];
void get_primes(int n)
{
    for (int i = 2; i <= n; i++)
    {
        if (!st[i]) primes[cnt++] = i;
        for (int j = 0; primes[j] <= n / i; j++)
        {
            st[primes[j] * i] = true;
            if (i % primes[j] == 0) break;
        }
    }
}
ll qmi(ll a, ll k, ll p)
{
    ll res = 1;
    while (k)
    {
        if (k & 1) res = res * a % p;
        a = a * a % p;
        k >>= 1;
    }
    return res;
}
int get(int a, int p)
{
    int res = 0;
    while (a) res += a / p, a /= p;
    return res;
}
ll C(ll a, ll b)
{
    ll res = 1;
    for (int i = 0; i < cnt; i++)
    {
        int p = primes[i];
        int s = get(a, p) - get(b, p) - get(a - b, p);
        res = res * qmi(p, s, mod) % mod;
    }
    return res;
}
int main()
{
    cin >> n >> mod;
    get_primes(n * 2);
    cout << ((C(2 * n, n) - C(2 * n, n - 1)) % mod + mod) % mod << endl;
    return 0;
}